package nosql.property;

import nosql.property.Property;
import nosql.property.PropertySet;
import nosql.property.PropertySetBuilder;
import nosql.property.PropertySetTranslateException;

import org.json.simple.parser.ParseException;

public class TestParseJsonToPropertySet {
	
	public static void translateTest() throws ParseException, PropertySetTranslateException {

		String[] json = {
			"{\"a\":10, \"b\":2.2, \"c\":\"str\"}",	//	simple
			"{\"a\":{\"b\":22, \"c\":33}, \"d\":44, \"e\":55}",	//	embeded
			"{\"a\": [{\"b\":1},{\"c\":2}]}",	//	complex array
			"[\"str\", \"string\"]",	//	array
			"{\"a\": 1.1, \"b\": [2.1,3.2], \"c\": [{\"d\":4}, {\"e\":5}], \"f\":{\"g\":11}}"	//	complicate object
		};
		for(int i = 0; i < json.length; ++i){
			System.out.println("\n\n" + i + ":" + json[i] + "\n");
			PropertySetBuilder builder = new PropertySetBuilder();
			PropertySet set = builder.store(json[i]);
			for (Property property : set) {
				System.out.println(property);
			}
		}
	}
	
	public static void main(String[] args) throws Exception{
		translateTest();
	}
}
